﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BuildOptimizer
{
    class BoTask
    {
        private int _timeLeft = -1;
        private actionDelegate _action = null;

        public BoTask(int timeLeft, actionDelegate action)
        {
            _timeLeft = timeLeft;
            _action = action;
        }
        private BoTask(BoTask task)
        {
            _timeLeft = task._timeLeft;
            _action = task._action;
        }
        public BoTask clone()
        {
            return new BoTask(this);
        }

        public bool isExecuted(BoDecisionNode n)
        {
            if (_timeLeft == 0)
            {
                _action(n);
                return true;
            }
            else
            {
                _timeLeft -= 1;
                return false;
            }
        }
    }
}
